\(\int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx\) [173]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 46 \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=\frac {x}{a+b}-\frac {\sqrt {a} \arctan \left (\frac {\sqrt {b} \tanh (c+d x)}{\sqrt {a}}\right )}{\sqrt {b} (a+b) d} \]

[Out]

x/(a+b)-arctan(b^(1/2)*tanh(d*x+c)/a^(1/2))*a^(1/2)/(a+b)/d/b^(1/2)

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.174, Rules used = {3751, 492, 212, 211} \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=\frac {x}{a+b}-\frac {\sqrt {a} \arctan \left (\frac {\sqrt {b} \tanh (c+d x)}{\sqrt {a}}\right )}{\sqrt {b} d (a+b)} \]

[In]

Int[Tanh[c + d*x]^2/(a + b*Tanh[c + d*x]^2),x]

[Out]

x/(a + b) - (Sqrt[a]*ArcTan[(Sqrt[b]*Tanh[c + d*x])/Sqrt[a]])/(Sqrt[b]*(a + b)*d)

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 492

Int[((e_.)*(x_))^(m_.)/(((a_) + (b_.)*(x_)^(n_))*((c_) + (d_.)*(x_)^(n_))), x_Symbol] :> Dist[(-a)*(e^n/(b*c -
 a*d)), Int[(e*x)^(m - n)/(a + b*x^n), x], x] + Dist[c*(e^n/(b*c - a*d)), Int[(e*x)^(m - n)/(c + d*x^n), x], x
] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && LeQ[n, m, 2*n - 1]

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {x^2}{\left (1-x^2\right ) \left (a+b x^2\right )} \, dx,x,\tanh (c+d x)\right )}{d} \\ & = \frac {\text {Subst}\left (\int \frac {1}{1-x^2} \, dx,x,\tanh (c+d x)\right )}{(a+b) d}-\frac {a \text {Subst}\left (\int \frac {1}{a+b x^2} \, dx,x,\tanh (c+d x)\right )}{(a+b) d} \\ & = \frac {x}{a+b}-\frac {\sqrt {a} \arctan \left (\frac {\sqrt {b} \tanh (c+d x)}{\sqrt {a}}\right )}{\sqrt {b} (a+b) d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.04 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.02 \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=\frac {-\frac {\sqrt {a} \arctan \left (\frac {\sqrt {b} \tanh (c+d x)}{\sqrt {a}}\right )}{\sqrt {b}}+\text {arctanh}(\tanh (c+d x))}{(a+b) d} \]

[In]

Integrate[Tanh[c + d*x]^2/(a + b*Tanh[c + d*x]^2),x]

[Out]

(-((Sqrt[a]*ArcTan[(Sqrt[b]*Tanh[c + d*x])/Sqrt[a]])/Sqrt[b]) + ArcTanh[Tanh[c + d*x]])/((a + b)*d)

Maple [A] (verified)

Time = 0.12 (sec) , antiderivative size = 72, normalized size of antiderivative = 1.57

method result size
derivativedivides \(\frac {\frac {\ln \left (\tanh \left (d x +c \right )+1\right )}{2 a +2 b}-\frac {a \arctan \left (\frac {b \tanh \left (d x +c \right )}{\sqrt {a b}}\right )}{\left (a +b \right ) \sqrt {a b}}-\frac {\ln \left (\tanh \left (d x +c \right )-1\right )}{2 a +2 b}}{d}\) \(72\)
default \(\frac {\frac {\ln \left (\tanh \left (d x +c \right )+1\right )}{2 a +2 b}-\frac {a \arctan \left (\frac {b \tanh \left (d x +c \right )}{\sqrt {a b}}\right )}{\left (a +b \right ) \sqrt {a b}}-\frac {\ln \left (\tanh \left (d x +c \right )-1\right )}{2 a +2 b}}{d}\) \(72\)
risch \(\frac {x}{a +b}+\frac {\sqrt {-a b}\, \ln \left ({\mathrm e}^{2 d x +2 c}-\frac {2 \sqrt {-a b}-a +b}{a +b}\right )}{2 b \left (a +b \right ) d}-\frac {\sqrt {-a b}\, \ln \left ({\mathrm e}^{2 d x +2 c}+\frac {2 \sqrt {-a b}+a -b}{a +b}\right )}{2 b \left (a +b \right ) d}\) \(108\)

[In]

int(tanh(d*x+c)^2/(a+b*tanh(d*x+c)^2),x,method=_RETURNVERBOSE)

[Out]

1/d*(1/(2*a+2*b)*ln(tanh(d*x+c)+1)-a/(a+b)/(a*b)^(1/2)*arctan(b*tanh(d*x+c)/(a*b)^(1/2))-1/(2*a+2*b)*ln(tanh(d
*x+c)-1))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 81 vs. \(2 (38) = 76\).

Time = 0.29 (sec) , antiderivative size = 486, normalized size of antiderivative = 10.57 \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=\left [\frac {2 \, d x + \sqrt {-\frac {a}{b}} \log \left (\frac {{\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right )^{4} + 4 \, {\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} + {\left (a^{2} + 2 \, a b + b^{2}\right )} \sinh \left (d x + c\right )^{4} + 2 \, {\left (a^{2} - b^{2}\right )} \cosh \left (d x + c\right )^{2} + 2 \, {\left (3 \, {\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right )^{2} + a^{2} - b^{2}\right )} \sinh \left (d x + c\right )^{2} + a^{2} - 6 \, a b + b^{2} + 4 \, {\left ({\left (a^{2} + 2 \, a b + b^{2}\right )} \cosh \left (d x + c\right )^{3} + {\left (a^{2} - b^{2}\right )} \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) - 4 \, {\left ({\left (a b + b^{2}\right )} \cosh \left (d x + c\right )^{2} + 2 \, {\left (a b + b^{2}\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) + {\left (a b + b^{2}\right )} \sinh \left (d x + c\right )^{2} + a b - b^{2}\right )} \sqrt {-\frac {a}{b}}}{{\left (a + b\right )} \cosh \left (d x + c\right )^{4} + 4 \, {\left (a + b\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} + {\left (a + b\right )} \sinh \left (d x + c\right )^{4} + 2 \, {\left (a - b\right )} \cosh \left (d x + c\right )^{2} + 2 \, {\left (3 \, {\left (a + b\right )} \cosh \left (d x + c\right )^{2} + a - b\right )} \sinh \left (d x + c\right )^{2} + 4 \, {\left ({\left (a + b\right )} \cosh \left (d x + c\right )^{3} + {\left (a - b\right )} \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) + a + b}\right )}{2 \, {\left (a + b\right )} d}, \frac {d x - \sqrt {\frac {a}{b}} \arctan \left (\frac {{\left ({\left (a + b\right )} \cosh \left (d x + c\right )^{2} + 2 \, {\left (a + b\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right ) + {\left (a + b\right )} \sinh \left (d x + c\right )^{2} + a - b\right )} \sqrt {\frac {a}{b}}}{2 \, a}\right )}{{\left (a + b\right )} d}\right ] \]

[In]

integrate(tanh(d*x+c)^2/(a+b*tanh(d*x+c)^2),x, algorithm="fricas")

[Out]

[1/2*(2*d*x + sqrt(-a/b)*log(((a^2 + 2*a*b + b^2)*cosh(d*x + c)^4 + 4*(a^2 + 2*a*b + b^2)*cosh(d*x + c)*sinh(d
*x + c)^3 + (a^2 + 2*a*b + b^2)*sinh(d*x + c)^4 + 2*(a^2 - b^2)*cosh(d*x + c)^2 + 2*(3*(a^2 + 2*a*b + b^2)*cos
h(d*x + c)^2 + a^2 - b^2)*sinh(d*x + c)^2 + a^2 - 6*a*b + b^2 + 4*((a^2 + 2*a*b + b^2)*cosh(d*x + c)^3 + (a^2
- b^2)*cosh(d*x + c))*sinh(d*x + c) - 4*((a*b + b^2)*cosh(d*x + c)^2 + 2*(a*b + b^2)*cosh(d*x + c)*sinh(d*x +
c) + (a*b + b^2)*sinh(d*x + c)^2 + a*b - b^2)*sqrt(-a/b))/((a + b)*cosh(d*x + c)^4 + 4*(a + b)*cosh(d*x + c)*s
inh(d*x + c)^3 + (a + b)*sinh(d*x + c)^4 + 2*(a - b)*cosh(d*x + c)^2 + 2*(3*(a + b)*cosh(d*x + c)^2 + a - b)*s
inh(d*x + c)^2 + 4*((a + b)*cosh(d*x + c)^3 + (a - b)*cosh(d*x + c))*sinh(d*x + c) + a + b)))/((a + b)*d), (d*
x - sqrt(a/b)*arctan(1/2*((a + b)*cosh(d*x + c)^2 + 2*(a + b)*cosh(d*x + c)*sinh(d*x + c) + (a + b)*sinh(d*x +
 c)^2 + a - b)*sqrt(a/b)/a))/((a + b)*d)]

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 253 vs. \(2 (37) = 74\).

Time = 2.08 (sec) , antiderivative size = 253, normalized size of antiderivative = 5.50 \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=\begin {cases} \tilde {\infty } x & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {x - \frac {\tanh {\left (c + d x \right )}}{d}}{a} & \text {for}\: b = 0 \\\frac {x}{b} & \text {for}\: a = 0 \\\frac {d x \tanh ^{2}{\left (c + d x \right )}}{2 b d \tanh ^{2}{\left (c + d x \right )} - 2 b d} - \frac {d x}{2 b d \tanh ^{2}{\left (c + d x \right )} - 2 b d} + \frac {\tanh {\left (c + d x \right )}}{2 b d \tanh ^{2}{\left (c + d x \right )} - 2 b d} & \text {for}\: a = - b \\\frac {x \tanh ^{2}{\left (c \right )}}{a + b \tanh ^{2}{\left (c \right )}} & \text {for}\: d = 0 \\- \frac {a \log {\left (- \sqrt {- \frac {a}{b}} + \tanh {\left (c + d x \right )} \right )}}{2 a b d \sqrt {- \frac {a}{b}} + 2 b^{2} d \sqrt {- \frac {a}{b}}} + \frac {a \log {\left (\sqrt {- \frac {a}{b}} + \tanh {\left (c + d x \right )} \right )}}{2 a b d \sqrt {- \frac {a}{b}} + 2 b^{2} d \sqrt {- \frac {a}{b}}} + \frac {2 b d x \sqrt {- \frac {a}{b}}}{2 a b d \sqrt {- \frac {a}{b}} + 2 b^{2} d \sqrt {- \frac {a}{b}}} & \text {otherwise} \end {cases} \]

[In]

integrate(tanh(d*x+c)**2/(a+b*tanh(d*x+c)**2),x)

[Out]

Piecewise((zoo*x, Eq(a, 0) & Eq(b, 0) & Eq(d, 0)), ((x - tanh(c + d*x)/d)/a, Eq(b, 0)), (x/b, Eq(a, 0)), (d*x*
tanh(c + d*x)**2/(2*b*d*tanh(c + d*x)**2 - 2*b*d) - d*x/(2*b*d*tanh(c + d*x)**2 - 2*b*d) + tanh(c + d*x)/(2*b*
d*tanh(c + d*x)**2 - 2*b*d), Eq(a, -b)), (x*tanh(c)**2/(a + b*tanh(c)**2), Eq(d, 0)), (-a*log(-sqrt(-a/b) + ta
nh(c + d*x))/(2*a*b*d*sqrt(-a/b) + 2*b**2*d*sqrt(-a/b)) + a*log(sqrt(-a/b) + tanh(c + d*x))/(2*a*b*d*sqrt(-a/b
) + 2*b**2*d*sqrt(-a/b)) + 2*b*d*x*sqrt(-a/b)/(2*a*b*d*sqrt(-a/b) + 2*b**2*d*sqrt(-a/b)), True))

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 215 vs. \(2 (38) = 76\).

Time = 0.30 (sec) , antiderivative size = 215, normalized size of antiderivative = 4.67 \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=-\frac {{\left (a - b\right )} \arctan \left (\frac {{\left (a + b\right )} e^{\left (2 \, d x + 2 \, c\right )} + a - b}{2 \, \sqrt {a b}}\right )}{4 \, \sqrt {a b} {\left (a + b\right )} d} + \frac {\arctan \left (\frac {{\left (a + b\right )} e^{\left (-2 \, d x - 2 \, c\right )} + a - b}{2 \, \sqrt {a b}}\right )}{2 \, \sqrt {a b} d} + \frac {{\left (a - b\right )} \arctan \left (\frac {{\left (a + b\right )} e^{\left (-2 \, d x - 2 \, c\right )} + a - b}{2 \, \sqrt {a b}}\right )}{4 \, \sqrt {a b} {\left (a + b\right )} d} + \frac {\log \left ({\left (a + b\right )} e^{\left (4 \, d x + 4 \, c\right )} + 2 \, {\left (a - b\right )} e^{\left (2 \, d x + 2 \, c\right )} + a + b\right )}{4 \, {\left (a + b\right )} d} - \frac {\log \left (2 \, {\left (a - b\right )} e^{\left (-2 \, d x - 2 \, c\right )} + {\left (a + b\right )} e^{\left (-4 \, d x - 4 \, c\right )} + a + b\right )}{4 \, {\left (a + b\right )} d} \]

[In]

integrate(tanh(d*x+c)^2/(a+b*tanh(d*x+c)^2),x, algorithm="maxima")

[Out]

-1/4*(a - b)*arctan(1/2*((a + b)*e^(2*d*x + 2*c) + a - b)/sqrt(a*b))/(sqrt(a*b)*(a + b)*d) + 1/2*arctan(1/2*((
a + b)*e^(-2*d*x - 2*c) + a - b)/sqrt(a*b))/(sqrt(a*b)*d) + 1/4*(a - b)*arctan(1/2*((a + b)*e^(-2*d*x - 2*c) +
 a - b)/sqrt(a*b))/(sqrt(a*b)*(a + b)*d) + 1/4*log((a + b)*e^(4*d*x + 4*c) + 2*(a - b)*e^(2*d*x + 2*c) + a + b
)/((a + b)*d) - 1/4*log(2*(a - b)*e^(-2*d*x - 2*c) + (a + b)*e^(-4*d*x - 4*c) + a + b)/((a + b)*d)

Giac [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.41 \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=-\frac {\frac {a \arctan \left (\frac {a e^{\left (2 \, d x + 2 \, c\right )} + b e^{\left (2 \, d x + 2 \, c\right )} + a - b}{2 \, \sqrt {a b}}\right )}{\sqrt {a b} {\left (a + b\right )}} - \frac {d x + c}{a + b}}{d} \]

[In]

integrate(tanh(d*x+c)^2/(a+b*tanh(d*x+c)^2),x, algorithm="giac")

[Out]

-(a*arctan(1/2*(a*e^(2*d*x + 2*c) + b*e^(2*d*x + 2*c) + a - b)/sqrt(a*b))/(sqrt(a*b)*(a + b)) - (d*x + c)/(a +
 b))/d

Mupad [B] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.83 \[ \int \frac {\tanh ^2(c+d x)}{a+b \tanh ^2(c+d x)} \, dx=\frac {x}{a+b}-\frac {a\,\mathrm {atan}\left (\frac {b\,\mathrm {tanh}\left (c+d\,x\right )}{\sqrt {a\,b}}\right )}{d\,\sqrt {a\,b}\,\left (a+b\right )} \]

[In]

int(tanh(c + d*x)^2/(a + b*tanh(c + d*x)^2),x)

[Out]

x/(a + b) - (a*atan((b*tanh(c + d*x))/(a*b)^(1/2)))/(d*(a*b)^(1/2)*(a + b))